package com.bj.dz.controller;

import com.bj.dz.entity.SingleBuilding;
import com.bj.dz.service.SingleBuildingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/***
*   控制器
*/
@Slf4j
@Api(tags = "【singleBuilding】提供服务接口")
@RestController
@RequestMapping("/singleBuilding")
public class SingleBuildingController {

    @Resource
    private SingleBuildingService singleBuildingService;

    /**
    * 通过id查询
    * @param
    * @return
    */
    @ApiOperation(value = "查找服务")
    @RequestMapping(value="/findById",method = RequestMethod.POST, produces = "application/json;" +"charset=UTF-8")
    public SingleBuilding findSingleBuildingById(@ApiParam(name = "id",value = "SingleBuilding的id",required = true) @RequestParam(value = "id",required=true)Integer id){
        return singleBuildingService.getSingleBuildingById(id);
    }

    /**
    * 通过多个查询
    * @param
    * @return
    */
    @ApiOperation(value = "查找多个服务")
    @RequestMapping(value="/findSingleBuildings",method = RequestMethod.POST, produces = "application/json;" +"charset=UTF-8")
    public List<SingleBuilding> findSingleBuildingListByMap(@ApiParam(name = "SingleBuilding",value = "singleBuilding",required = true)@RequestBody SingleBuilding singleBuilding){

        return singleBuildingService.getSingleBuildingListByMap(null);
    }

    /**
    * 查询总数
    * @param
    * @return
    */
    @ApiOperation(value = "获取总数服务")
    @RequestMapping(value="/count",method = RequestMethod.POST, produces = "application/json;" +"charset=UTF-8")
    public Integer SingleBuildingCount(){
        return singleBuildingService.getSingleBuildingCountByMap(null);
    }

    /**
    * 添加保存
    * @param
    * @return
    */
    @ApiOperation(value = "添加服务")
    @RequestMapping(value="/add",method = RequestMethod.POST, produces = "application/json;" +"charset=UTF-8")
    public boolean addSingleBuilding(@ApiParam(name = "SingleBuilding",value = "singleBuilding对象",required = true)@RequestBody SingleBuilding singleBuilding){
            return singleBuildingService.addSingleBuilding(singleBuilding);
    }

    /**
    * 更新修改
    * @param
    * @return
    */
    @ApiOperation(value = "更新修改服务")
    @RequestMapping(value="/upd",method = RequestMethod.POST, produces = "application/json;" +"charset=UTF-8")
    public boolean modifySingleBuilding(@ApiParam(name = "SingleBuilding",value = "singleBuilding对象",required = true)@RequestBody SingleBuilding singleBuilding){
        return singleBuildingService.modifySingleBuilding(singleBuilding);
    }

    /**
    * 删除
    * @param
    * @return
    */
    @ApiOperation(value = "删除服务")
    @RequestMapping(value="/del",method = RequestMethod.POST, produces = "application/json;" +"charset=UTF-8")
    public boolean deleteSingleBuildingById(@ApiParam(name = "SingleBuilding",value = "singleBuilding的id",required = true) @RequestParam(value = "id",required=true)Integer id){
        return singleBuildingService.deleteSingleBuildingById(id);
    }



}
